package di.scanner.store;

import di.scanner.model.JavaClassElement;

import java.util.concurrent.ConcurrentLinkedQueue;

public class JavaClassStore implements Store<JavaClassElement> {

    private ConcurrentLinkedQueue<JavaClassElement> javaClassElementStore;

    private static JavaClassStore javaClassStore;

    private JavaClassStore() {
        javaClassElementStore = new ConcurrentLinkedQueue<JavaClassElement>();
    }

    public static JavaClassStore getInstance() {
        if (javaClassStore==null){
            synchronized (JavaClassStore.class){
                if (javaClassStore==null){
                    javaClassStore = new JavaClassStore();
                }
            }
        }
        return javaClassStore;
    }

    public void add(JavaClassElement javaClassElement) {
        javaClassElementStore.add(javaClassElement);
       // System.out.println(javaClassElement.toString());
    }

    public JavaClassElement poll() {
        return javaClassElementStore.poll();
    }
}
